package com.enfi.api.modules.db.entity;

import java.util.Date;
import java.io.Serializable;
import java.util.List;
import javax.persistence.*;

import com.enfi.api.modules.db.base.BaseEntity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import lombok.*;




/**
 * 待办列表 包含财务审批和工作联络单(Workorder)实体类
 *
 * @author wind
 * @since 2020-04-10 12:01:45
 */
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name="t_tbl_workorder")
@DynamicInsert
@DynamicUpdate
public class Workorder extends BaseEntity<Integer> {


    /**
     * 待办来源 1厂控系统 2管网GIS
     */    
    private Integer source;

    /**
     * 原始ID，平台方工单ID
     */    
    private String sourceId;

    /**
     * 子公司编码
     */    
    private String officeCode;

    /**
     * 子公司名称
     */    
    private String officeName;

    /**
     * 工厂编码
     */    
    private String factoryCode;

    /**
     * 工厂名称
     */    
    private String factory;

    /**
     * 待办类型 1财务审批 2工作联络单
     */    
    private Integer type;

    /**
     * 待办标题
     */    
    private String title;

    /**
     * 待办等级 1一般 2紧急
     */    
    private Integer level;

    /**
     * 待办状态 中文
     */    
    private String status;

    /**
     * 待办时间，此时间为操作的最新时间
     */    
    private Date operTime;

    /**
     * 待办链接地址，页面中用需拼接token跳转至厂控系统
     */    
    private String url;

    /**
     * 创建时间
     */
    @CreatedDate
    private Date createTime;

    /**
     * 修改时间
     */
    @LastModifiedDate
    private Date updateTime;

        
    private Integer workorderStatus;

    /**
     * 处理人
     */    
    private String userWorkNumbers;

    /**
     * uuid
     */    
    private String uuid;

    /**
     * 版本
     */
    @Version
    private Integer version;

    @OneToMany(fetch = FetchType.LAZY,targetEntity =WorkorderUser.class,cascade = {CascadeType.ALL})
    @JoinColumn(name = "workorderId")
    @NotFound
    @JsonIgnore
    private List<WorkorderUser> workorderUsers;
    @Transient
    private WorkorderUser workorderUser;
}